/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.converter;

import br.com.foxline.model.Construction;
import br.com.foxline.model.TypeLot;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author roniere
 */
@FacesConverter(value = "typelotconverter")
public class TypeLotConverter implements Converter{

    public TypeLotConverter() {
    }

    
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        if(!value.equals("null") && !value.equals("")){
            TypeLot typeLot = new TypeLot();
            typeLot.setId((Long.valueOf(value)));
            return typeLot;
        }
        return null;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if(value != null){
            return ((TypeLot) value).getId()+"";
        }
        return null;
    }
    
}
